﻿<Window x:Class="Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Validation Tool" Height="600" Width="1050" MinHeight="500" MinWidth="900" WindowStartupLocation="CenterScreen">
    <Window.Resources>

        <Style x:Key="MachineListBoxStyle" TargetType="{x:Type ListBox}" >
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBox}" >
                        <WrapPanel Margin="3" IsItemsHost="True" 
                                   Orientation="Horizontal" 
                                   VerticalAlignment="Stretch" 
                                   HorizontalAlignment="Stretch" 
                                   Background="Transparent"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="CollectionItemStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}" >
                        <Border SnapsToDevicePixels="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{TemplateBinding Background}">
                            <StackPanel Margin="10" Orientation="Horizontal">
                                <Image x:Name="Img" VerticalAlignment="Center" Source="/Images/Collection_Gray.png" Width="35" Height="35" Margin="0,0,5,2" />
                                <Label x:Name="GName" VerticalAlignment="Center" Content="{Binding DisplayName}" FontFamily="Arial" Foreground="#FF626262" FontSize="16" />
                            </StackPanel>
                            <Border.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Edit Collection" Click="CollectionOperation_Click"/>
                                    <MenuItem Header="Delete Collection" Click="CollectionOperation_Click"/>
                                </ContextMenu>
                            </Border.ContextMenu>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="Transparent" />
                                <Setter TargetName="Img" Property="Source" Value="/Images/Collection_Blue.png" />
                                <Setter TargetName="GName" Property="Foreground" Value="#FF3AAEE3" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="MachineItemStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}" >
                        <Border SnapsToDevicePixels="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{TemplateBinding Background}">
                            <ContentPresenter />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="#FFF0F0F0" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Headers for metadata properties -->
        <Style x:Key="MetadataHeader" TargetType="{x:Type Label}">
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5" >
                        <GradientStop Offset="0.5" Color="#FF0072C6" />
                        <GradientStop Offset="6" Color="Transparent" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontWeight" Value="Bold" />
        </Style>

    </Window.Resources>
    <Grid x:Name="root">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <!-- content view -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="280" MinWidth="240"/>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel Grid.Row="0" Orientation="Horizontal" Height="40" Background="#FF0072C6">
                    <TextBlock Text="SERVER COLLECTIONS" FontFamily="Arial" FontSize="16" VerticalAlignment="Center" Margin="13,0,0,0" Foreground="White" FontWeight="Black"/>
                </StackPanel>
                <ListBox Grid.Row="1" 
                         x:Name="listCollections" 
                         ItemsSource="{Binding Collections}" 
                         SelectionChanged="listCollections_SelectionChanged" 
                         ItemContainerStyle="{StaticResource CollectionItemStyle}" BorderThickness="1,1,1,0" Background="#FFF4F4F4" BorderBrush="#FFD4D4D4"
                         >
                    <ListBox.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Add Collection" Click="CollectionOperation_Click"/>
                        </ContextMenu>
                    </ListBox.ContextMenu>
                </ListBox>
            </Grid>
            <GridSplitter HorizontalAlignment="Right" VerticalAlignment="Stretch" Grid.Column="1" ResizeBehavior="PreviousAndNext" Width="1" Background="White" Margin="0"/>
            <Grid Grid.Column="2" Margin="5,0,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="40" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderThickness="0,0,0,1" BorderBrush="#FFD4D4D4" Margin="0">
                    <Grid>
                        <TextBlock Text="SERVERS" FontSize="16" VerticalAlignment="Center" Margin="5,0,0,0" FontFamily="Arial" Foreground="Black" FontWeight="Black"/>
                        <Image VerticalAlignment="Center" HorizontalAlignment="Right" Source="/Images/Help.png" Width="20" Height="20" Margin="0,0,10,0" MouseLeftButtonUp="Image_MouseLeftButtonUp" />
                    </Grid>
                </Border>
                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0" Background="White">
                        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
                            <ListBox x:Name="listMachines" 
                             Style="{StaticResource MachineListBoxStyle}" 
                             DataContext="{Binding CurrentCollection}" 
                             ItemsSource="{Binding Machines}" 
                             ItemContainerStyle="{StaticResource MachineItemStyle}"
                             SelectionChanged="listMachines_SelectionChanged"
                             >
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Background="Transparent">
                                            <Grid.ContextMenu>
                                                <ContextMenu>
                                                    <MenuItem Header="Verify Server" Click="MachineVerify_Click" IsEnabled="{Binding Status, Converter={StaticResource MachineContextMenuConverters}, ConverterParameter=Validation }"/>
                                                    <Separator />
                                                    <MenuItem Header="Copy Directory" Click="CopyDirectory_Click" IsEnabled="{Binding Status, Converter={StaticResource MachineContextMenuConverters}, ConverterParameter=CopyDirectory}"/>
                                                    <Separator />
                                                    <MenuItem Header="Edit Server" Click="MachineOperation_Click" IsEnabled="{Binding Status, Converter={StaticResource MachineContextMenuConverters}, ConverterParameter=EditServer}"/>
                                                    <MenuItem Header="Delete Server" Click="MachineOperation_Click" IsEnabled="{Binding Status, Converter={StaticResource MachineContextMenuConverters}, ConverterParameter=DeleteServer}"/>
                                                    <Separator />
                                                    <MenuItem Header="Validation Service" IsEnabled="{Binding Status, Converter={StaticResource MachineContextMenuConverters}, ConverterParameter=Service}">
                                                        <MenuItem Header="Install" Click="InsatllService_Click" IsEnabled="{Binding Status, Converter={StaticResource MachineContextMenuConverters}, ConverterParameter=ServiceInstall}"/>
                                                        <MenuItem Header="Uninstall" Click="InsatllService_Click" IsEnabled="{Binding Status, Converter={StaticResource MachineContextMenuConverters}, ConverterParameter=ServiceUninstall}"/>
                                                        <MenuItem Header="Re-Install" Click="InsatllService_Click" IsEnabled="{Binding Status, Converter={StaticResource MachineContextMenuConverters}, ConverterParameter=ServiceReinstall}"/>
                                                    </MenuItem>
                                                </ContextMenu>
                                            </Grid.ContextMenu>
                                            <Grid Margin="40,20">
                                                <StackPanel>
                                                    <Image Source="/Images/Machine.png" Width="65" Height="65" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                                    <StackPanel Margin="5,10,5,5" Orientation="Horizontal">
                                                        <Rectangle Grid.Column="0" Width="30" Height="30" Fill="{Binding Status, Converter={StaticResource MachineStatusConverters}}" Margin="0,0,0,0"/>
                                                        <StackPanel Margin="7,0,0,0">
                                                            <TextBlock VerticalAlignment="Center" Text="{Binding DisplayName}" FontFamily="Arial" FontSize="15" FontWeight="Black"/>
                                                            <TextBlock VerticalAlignment="Center" Text="{Binding ServerIP}" Margin="0,2,0,0"  FontFamily="Arial"/>
                                                        </StackPanel>
                                                    </StackPanel>
                                                </StackPanel>
                                            </Grid>
                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                                <ListBox.ContextMenu>
                                    <ContextMenu>
                                        <MenuItem Header="Add Server" Click="MachineOperation_Click"/>
                                    </ContextMenu>
                                </ListBox.ContextMenu>
                            </ListBox>
                        </ScrollViewer>
                    </Grid>
                    <Border Grid.Column="1" BorderThickness="1,0" BorderBrush="#FFD4D4D4" MinWidth="220" 
                    Visibility="{Binding CurrentMachine, Converter={StaticResource SelectServerConverters}}">
                        <ScrollViewer Margin="3,3,3,3" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
                            <StackPanel>
                                <Label Style="{StaticResource MetadataHeader}" Content="DOMAIN NAME:"/>
                                <Label Content="{Binding CurrentMachine.DomainName}" BorderThickness="0,0,0,3" />
                                <Label Style="{StaticResource MetadataHeader}" Content="SERVER NAME:"/>
                                <Label Content="{Binding CurrentMachine.ServerName}" BorderThickness="0,0,0,3" />
                                <Label Style="{StaticResource MetadataHeader}" Content="OPERATION SYSTEM:"/>
                                <Label Content="{Binding CurrentMachine.OSName}" BorderThickness="0,0,0,3" />
                                <Label Style="{StaticResource MetadataHeader}" Content="OPERATION VERSION:"/>
                                <Label Content="{Binding CurrentMachine.OSVersion}" BorderThickness="0,0,0,3" />
                                <Label Style="{StaticResource MetadataHeader}" Content="IS 64 BIT OS:"/>
                                <Label Content="{Binding CurrentMachine.Is64BitOS}" BorderThickness="0,0,0,3" />
                                <Label Style="{StaticResource MetadataHeader}" Content="SERVICE VERSION:"/>
                                <Label Content="{Binding CurrentMachine.ServiceVersion}" BorderThickness="0,0,0,3" />
                            </StackPanel>
                        </ScrollViewer>
                    </Border>
                </Grid>
            </Grid>
        </Grid>
        <!-- buttom bar -->
        <Border Grid.Row="1" Background="#FF0072C6">
            <Grid>
                <TextBlock Text="EMC SourceOne - Installation Validation Utility" 
                           Margin="0,0,10,0"
                           Foreground="White"
                           FontSize="15"
                           HorizontalAlignment="Right" 
                           VerticalAlignment="Center"/>
            </Grid>
        </Border>
    </Grid>
</Window>
